using HKB.Common;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Web;
namespace HKB.Web
{
	public class Shop_Complain
	{
		private Conn conn = null;
		private Pagination _pageHand = null;
		protected Pagination pageHand
		{
			get
			{
				Pagination pageHand;
				if (this._pageHand == null)
				{
					this._pageHand = new Pagination();
					this._pageHand.SQL_CloseTablePre = false;
					this._pageHand.P_Object = Language.GetAdminMsg("Review/ReviewName");
					pageHand = this._pageHand;
				}
				else
				{
					pageHand = this._pageHand;
				}
				return pageHand;
			}
		}
		public Shop_Complain()
		{
			this.conn = Text.GetComponent<Conn>("conn", HttpContext.Current.CurrentHandler);
		}
		public Shop_Complain(Conn _conn)
		{
			this.conn = _conn;
		}
		public DataTable GetAllComplains(int indexpage, int maxperpage, string WhereStr, string OrderStr)
		{
			return this.pageHand.GetDataTable("HLShop_Complain", indexpage, maxperpage, "ComplainID", WhereStr, OrderStr, this.conn, null);
		}
		public DataTable GetAllComplains(int indexpage, int maxperpage, string WhereStr, string OrderStr, params IDbDataParameter[] param)
		{
			return this.pageHand.GetDataTable("HLShop_Complain", indexpage, maxperpage, "ComplainID", WhereStr, OrderStr, this.conn, param);
		}
		public string GetPagePanel(string LinkHead)
		{
			this.pageHand.P_LinkHead = LinkHead;
			return this.pageHand.ShowPagePanel();
		}
		public bool AddComplain(int UserID, string ComplainType, int ComplainUserID, string ComplainUserName, string Reason, int Status, string Result, DateTime StartTime, string UserName)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@UserID", DbType.Int32, UserID),
				this.conn.CreateParameter("@ComplainType", DbType.String, ComplainType),
				this.conn.CreateParameter("@ComplainUserID", DbType.Int32, ComplainUserID),
				this.conn.CreateParameter("@ComplainUserName", DbType.String, ComplainUserName),
				this.conn.CreateParameter("@Reason", DbType.String, Reason),
				this.conn.CreateParameter("@Status", DbType.Boolean, Status),
				this.conn.CreateParameter("@Result", DbType.String, Result),
				this.conn.CreateParameter("@StartTime", DbType.DateTime, StartTime),
				this.conn.CreateParameter("@UserName", DbType.String, UserName)
			};
			string commandText = "INSERT INTO [HLShop_Complain] ([UserID], [ComplainType], [ComplainUserID], [ComplainUserName], [Reason], [Status], [Result], [StartTime], [UserName]) VALUES (@UserID, @ComplainType, @ComplainUserID, @ComplainUserName, @Reason, @Status, @Result, @StartTime, @UserName)";
			int num = this.conn.Execute(commandText, parameters);
			return num > 0;
		}
		public bool EditComplainResultByComplainID(int ComplainID, int Status, string Result)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@ComplainID", DbType.Int32, ComplainID),
				this.conn.CreateParameter("@Status", DbType.Boolean, Status),
				this.conn.CreateParameter("@Result", DbType.String, Result)
			};
			string commandText = "UPDATE [HLShop_Complain] SET [Status] =@Status,[Result] =@Result WHERE ComplainID=@ComplainID";
			int num = this.conn.Execute(commandText, parameters);
			return num > 0;
		}
		public DataTable GetComplainByComplainID(int ComplainID)
		{
			return this.conn.GetDataTable("SELECT * From [HLShop_Complain] Where [ComplainID]=" + ComplainID);
		}
		public bool UpdateComplain(int ComplainID, string Result)
		{
			IDbDataParameter[] parameters = new IDbDataParameter[]
			{
				this.conn.CreateParameter("@Original_ComplainID", DbType.Int32, ComplainID),
				this.conn.CreateParameter("@Result", DbType.String, Result)
			};
			return this.conn.Execute("UPDATE [HLShop_Complain] SET [Status] = 1, [Result] = @Result WHERE (([ComplainID] = @Original_ComplainID))", parameters) >= 1;
		}
		public bool DeleteComplain(int ComplainID)
		{
			return this.conn.Execute("DELETE From [HLShop_Complain] Where [ComplainID]=" + ComplainID) >= 1;
		}
		public DataTable GetComplainByStatusUserIDComplainUserIDLatelyDateComplainType(string Status, int? UserID, int? ComplainUserID, string LatelyDate, string ComplainType)
		{
			SqlParameter[] array = new SqlParameter[]
			{
				new SqlParameter("@RETURN_VALUE", SqlDbType.Int, 4, ParameterDirection.ReturnValue, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@Status", SqlDbType.VarChar, 20, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@UserID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@ComplainUserID", SqlDbType.Int, 4, ParameterDirection.Input, 10, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@LatelyDate", SqlDbType.VarChar, 20, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", ""),
				new SqlParameter("@ComplainType", SqlDbType.VarChar, 20, ParameterDirection.Input, 0, 0, null, DataRowVersion.Current, false, null, "", "", "")
			};
			if (Status == null)
			{
				array[0].Value = DBNull.Value;
			}
			else
			{
				array[1].Value = Status;
			}
			if (UserID.HasValue)
			{
				array[2].Value = UserID.Value;
			}
			else
			{
				array[2].Value = DBNull.Value;
			}
			if (ComplainUserID.HasValue)
			{
				array[3].Value = ComplainUserID.Value;
			}
			else
			{
				array[3].Value = DBNull.Value;
			}
			if (LatelyDate == null)
			{
				array[4].Value = DBNull.Value;
			}
			else
			{
				array[4].Value = LatelyDate;
			}
			if (ComplainType == null)
			{
				array[5].Value = DBNull.Value;
			}
			else
			{
				array[5].Value = ComplainType;
			}
			return this.conn.GetDataTable("PR_GetComplainByStatusUserIDComplainUserIDLatelyDateComplainType", array);
		}
		public DataTable getMyComplainByUserID(int UserID)
		{
			return this.conn.GetDataTable("SELECT * FROM HLShop_Complain Where UserID=" + UserID);
		}
		public DataTable getRevieComplainByUserID(int UserID)
		{
			return this.conn.GetDataTable("SELECT * FROM HLShop_Complain Where ComplainUserID=" + UserID);
		}
		public DataTable getComplainByWhereStr(string wherestr, int userID, int isComplainUserID, params IDbDataParameter[] param)
		{
			DataTable dataTable;
			if (isComplainUserID == 0)
			{
				if (wherestr == string.Empty || wherestr == null)
				{
					dataTable = this.conn.GetDataTable("Select * From [HLShop_Complain] Where userID=" + userID);
				}
				else
				{
					if (param != null)
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select * From [HLShop_Complain] Where ",
							wherestr,
							" and userID=",
							userID
						}), param);
					}
					else
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select * From [HLShop_Complain] Where ",
							wherestr,
							" and userID=",
							userID
						}));
					}
				}
			}
			else
			{
				if (wherestr == string.Empty || wherestr == null)
				{
					dataTable = this.conn.GetDataTable("Select * From [HLShop_Complain] Where ComplainUserID=" + userID);
				}
				else
				{
					if (param != null)
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select * From [HLShop_Complain] Where ",
							wherestr,
							" and ComplainUserID=",
							userID
						}), param);
					}
					else
					{
						dataTable = this.conn.GetDataTable(string.Concat(new object[]
						{
							"Select * From [HLShop_Complain] Where ",
							wherestr,
							" and ComplainUserID=",
							userID
						}));
					}
				}
			}
			return dataTable;
		}
	}
}
